
app.controller('taskModelCtrl', function ($scope) {
	var orderType = 1;
	
	requestData();
	
	/*
	请求数据
	*/
	function requestData() {
		var param = {
			orderType: orderType,
		};
		AQ.callAQ("getTaskModel.do", param, function(result) {
			var data = [];
			for (var i = 1; i < result.length; i++) {
				data.push({
					modelId: result[i].modelId,
					orderType: result[i].orderType,
					modelName: result[i].modelName,
					sellerNick: result[i].sellerNick,
					searchType: DIC.SearchType[result[i].searchType],
					modifyPrice: DIC.TrueFalse(result[i].modifyPrice),
					phoneOrder: DIC.PhoneOrder[result[i].phoneOrder],
					orderText: result[i].phoneOrder == 0 ? "电脑访问" : "手机访问",
					rateTime: DIC.RateTime[result[i].rateTime],
					noWordRate: DIC.TrueFalse(result[i].noWordRate),
					checkBuyerIp: DIC.TrueFalse(result[i].checkBuyerIp),
					takeArea: DIC.IsShow(result[i].takeArea),
					rankLimit: result[i].rankLimit,
					realName: DIC.TrueFalse(result[i].realName),
					checkTaker: DIC.TrueFalse(result[i].checkTaker),
					compare: DIC.TrueFalse(result[i].compare),
					browseOthers: DIC.TrueFalse(result[i].browseOthers),
					collect: DIC.TrueFalse(result[i].collect),
					stayTime: DIC.TrueFalse(result[i].stayTime),
					talk: DIC.TrueFalse(result[i].talk),
					browseFoot: DIC.TrueFalse(result[i].browseFoot),
					address: DIC.TrueFalse(result[i].address),					
					rateContent: result[i].rateContent,
					ratePicBt_isShow: false,
					rateSuccessPic: DIC.TrueFalse(result[i].rateSuccessPic),
					totalMoney: Utils.formatMoney(parseFloat(result[i].price) * parseInt(result[i].amount)),
					price: Utils.formatMoney(result[i].price),
					amount: result[i].amount,
					feibi: Utils.formatMoney(result[i].feibi),
					state: DIC.ExplaState[result[i].state],
					createTime: result[i].createTime,
				});
			}
			$scope.$apply(function () {
				$scope.listData = data;
			});
		}, function(err, code) {
			Utils.msgDialog(err + "["+ code +"]");
		});
	}
	
	$scope.deleteModel = function(modelId, modelName) {
		Utils.checkDialog("确定要删除放单模板“ "+ modelName +" ”吗？", "确定", "取消",
			function() {
				var param = {
					modelId: modelId,
				};
				AQ.callAQ("deleteTaskModel.do", param, function(result) {
					requestData();
				}, function(err, code) {
					Utils.msgDialog(err + "["+ code +"]");
				});
			},
			function() {}
		);
    };
	
	$("#model-sale").click(function() {
		orderType = 1;
        requestData();
    });
	$("#model-visit").click(function() {
		orderType = 2;
        requestData();
    });
	
	
});	//app.controller
